from flask import request, jsonify

from com.linkstec.service.company_info_service import CompanyInfoService

class CompanyInfoController:
    def __init__(self):
        self.service = CompanyInfoService()

    def get_company_info(self):
        data = request.json
        company = self.service.get_company_info(data['secc_name'])
        return jsonify(company.__dict__) if company else ('Not found', 404)

    def list_company_info(self):
        companys = self.service.list_company_info()
        return jsonify([u.__dict__ for u in companys])